package com.ruoyi.back.controller

import com.ruoyi.app.common.Data
import com.ruoyi.app.common.PageData
import com.ruoyi.back.domain.SystemNotice
import com.ruoyi.back.domain.dto.SystemNoticeSearchDto
import com.ruoyi.back.domain.vo.SystemNoticeDetailVo
import com.ruoyi.back.domain.vo.SystemNoticeListVo
import com.ruoyi.back.service.SystemNoticeService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("system/systemNotice")
@Api(tags = ["通知管理"])
class SystemNoticeController {

    @Autowired
    private lateinit var systemNoticeService: SystemNoticeService

    @ApiOperation("保存系统通知")
    @PostMapping("save")
    fun saveSystemNotice(@RequestBody systemNotice: SystemNotice) : Data<Boolean> =
        systemNoticeService.saveSystemNotice(systemNotice)

    @ApiOperation("系统通知分页")
    @GetMapping("page")
    fun systemNoticePage(systemNoticeSearchDto: SystemNoticeSearchDto): PageData<SystemNoticeListVo> =
        systemNoticeService.systemNoticePage(systemNoticeSearchDto)

    @ApiOperation("系统通知详情")
    @GetMapping("get/{id}")
    fun systemNoticeDetail(@PathVariable id: Long): Data<SystemNoticeDetailVo> =
        systemNoticeService.systemNoticeDetail(id)

    @ApiOperation("发送系统通知")
    @GetMapping("send")
    fun systemNoticeSend(systemNotice: SystemNotice): Data<Boolean> =
        systemNoticeService.systemNoticeSend(systemNotice)

    @ApiOperation("批量移除系统通知")
    @GetMapping("remove/{ids}")
    fun removeSystemNoticeSend(@PathVariable ids: String): Data<Boolean> =
        systemNoticeService.removeSystemNoticeSend(ids)
}